package me.algo.tree;

import java.util.LinkedList;

/**
 * @author guozheng
 * @date 2024/4/26
 */
public class T12 {
    public static void main(String[] args) {

    }

    public static boolean flipEquiv(TreeNode root1, TreeNode root2) {
        if (root1 == null) {
            if (root2 != null) {
                return false;
            } else {
                return true;
            }
        }
        if (root2 == null) {
            return false;
        }
        return root1.val == root2.val && (flipEquiv(root1.left, root2.right) || flipEquiv(root1.left, root2.left)) && (flipEquiv(root1.right, root2.left) || flipEquiv(root1.right, root2.right));
    }
}
